Full source code website bán hàng thương mại điện tử gần giống shopee
468.937 lượt xem;
1 <?
2 $path = "../images/cat";
3 $pathdb = "images/cat";
4 if (isset($_POST['butSaveLoai'])) {
5 $parent = $_POST['txtParent'];
6 $order = $_POST['txtSortOrder'];
7 if($order=='') $order=0;
8 else $order = $_POST['txtSortOrder'];
9
10 $status=($_POST['chkShow']!=''?1:0);
11
12 $CategoryName= trim($_POST['txtName']);
13 $err.=CheckUpload($_FILES["txtImage"],".jpg;.gif;.bmp;.png;.swf",500*1024,$_POST['id']==''?1:0);
14 if ($CategoryName=="")
15 {
16 echo "<p align=center class='err'>Bạn chưa nhập tên danh mục</p>";
17 }
18 else
19 {
20 $catinfo=GetCatInfo($parent);
21 $language=$catinfo['language'];
22 if (!empty($_POST['oldid'])) {
23 $oldid = $_POST['oldid'];
24 $sql = "update cat set name='".$CategoryName."', parent='".$parent."', thutu='".$order."', status=".$status." where id='".$oldid."'";
25 }
26 else
27 $sql = "insert into cat (name, parent, thutu, status) values ('".$CategoryName."','".$parent."','".$order."','".$status."')";
28 if (mysql_query($sql,$con)) {
29 if(empty($_POST['id'])) $oldid = mysql_insert_id();
30 $sqlUpdateField = "";
31 $extsmall=GetFileExtention($_FILES['txtImage']['name']);
32 if (MakeUpload($_FILES['txtImage'],"$path/cat_home_s$oldid$extsmall"))
33 {
34 @chmod("$path/cat_home_s$oldid$extsmall", 0777);
35 $sqlUpdateField = " image='$pathdb/cat_home_s$oldid$extsmall' ";
36 }
37 if($sqlUpdateField)
38 {
39 $sqlUpdate = "update cat set $sqlUpdateField where id='".$oldid."'";
40 mysql_query($sqlUpdate,$con);
41 }
42 echo "<p align=center class='err'>Đã cập nhật thành công</p><br>";
43 echo "<script>window.location='index.php?act=category&cat=".$_REQUEST['cat']."&page=".$_REQUEST['page']."'</script>";
44 }
45 else echo "<p align=center class='err'>Không thể cập nhật</p>";
46 }
47 }
48 ?>
49 <?
50 $path = "../images/cat";
51 $pathdb = "images/cat";
52 if (isset($_POST['butSaveLoai'])) {
53 $parent = $_POST['txtParent'];
54 $order = $_POST['txtSortOrder'];
55 if($order=='') $order=0;
56 else $order = $_POST['txtSortOrder'];
57 $status=($_POST['chkShow']!=''?1:0);
58 $CategoryName= trim($_POST['txtName']);
59
60 $err="";
61 if ($CategoryName=="") $err .= "Xin nhập tên<br>";
62 $err.=CheckUpload($_FILES["txtImage"],".jpg;.gif;.bmp;.png;.swf",500*1024,$_POST['id']==''?1:0);
63
64 if ($err=='')
65 {
66 if (!empty($_POST['id'])) {
67 $oldid = $_POST['id'];
68 $sql = "update cat set name='".$CategoryName."', parent='".$parent."', thutu='".$order."', status=".$status." where id='".$oldid."'";
69 }else {
70 $sql = "insert into cat (name, parent, thutu, status) values ('".$CategoryName."','".$parent."','".$order."','".$status."')";
71 }
72 if (mysql_query($sql,$con)) {
73 if(empty($_POST['id'])) $oldid = mysql_insert_id();
74
75 $sqlUpdateField = "";
76
77 $extsmall=GetFileExtention($_FILES['txtImage']['name']);
78 if (MakeUpload($_FILES['txtImage'],"$path/slider_home_s$oldid$extsmall"))
79 {
80 @chmod("$path/slider_home_s$oldid$extsmall", 0777);
81 $sqlUpdateField = " image='$pathdb/slider_home_s$oldid$extsmall' ";
82 }
83 if($sqlUpdateField)
84 {
85 $sqlUpdate = "update cat set $sqlUpdateField where id='".$oldid."'";
86 mysql_query($sqlUpdate,$con);
87 }
88 }
89 else {
90 $err = "<p align=center class='err'>Không thể cập nhật</p>";
91 }
92 }
93 if ($err=='') echo "<script>window.location='index.php?act=category&cat=".$_REQUEST['cat']."&page=".$_REQUEST['page']."'</script>";
94 else echo '<p align=center class="err" style="line-height: 150%">'.$err.'</p>';
95 }
96 ?>
97 <?
98 if (isset($_GET['id'])) {
99 $oldid=$_GET['id'];
100 $sql = "select * from cat where id='".$oldid."'";
101 if ($result = mysql_query($sql,$con)) {
102 $row=mysql_fetch_array($result);
103 $CategoryName=$row['name'];
104 $image=$row['image'];
105 $parent=$row['parent'];
106 $order=$row['thutu'];
107 $status=$row['status'];
108 $date=$row['date'];
109 }
110 }
111 ?>
112
113 <form method="POST" name="FormLoaiSP" enctype="multipart/form-data" action="index.php">
114 <input type=hidden name="act" value="category_m">
115 <input type=hidden name="oldid" value="<? echo $oldid; ?>">
116 <input type=hidden name="page" value="<? echo $_REQUEST['page']; ?>">
117 <input type=hidden name="cat" value="<? echo $_REQUEST['cat']; ?>">
118 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
119 <tr>
120 <td width="45%" align="center" class="title" height="20">Thêm mới / Cập nhật : Danh mục sản phẩm</td>
121 </tr>
122 <tr>
123 <td width="45%">
124 <table border="0" cellpadding="4" bordercolor="#111111" width="124%" id="AutoNumber2" cellspacing="0">
125 <tr>
126 <td width="15%" class="smallfont">
127 <p align="right">Tên danh mục</td>
128 <td width="1%" class="smallfont">
129 <font color="#FF0000">*</font></td>
130 <td width="83%" class="smallfont">
131 <INPUT value="<? echo $CategoryName; ?>" TYPE="text" NAME="txtName" CLASS=textbox size="34"></td>
132 </tr>
133 <tr>
134 <td width="15%" class="smallfont">
135 <p align="right">Hình Icon</td>
136 <td width="1%" class="smallfont" align="center">
137 </td>
138 <td width="83%" class="smallfont">
139 <INPUT TYPE="file" NAME="txtImage" CLASS=textbox size="34"></td>
140 </tr>
141 <tr>
142 <td width="15%" class="smallfont">
143 <p align="right">Thuộc danh mục</td>
144 <td width="1%" class="smallfont">
145 </td>
146 <td width="83%" class="smallfont">
147 <select size="1" name="txtParent">
148 <?
149 echo "<option value='17'>[Danh mục gốc]</option>";
150 $cats=GetListCat(17);
151 foreach ($cats as $cat)
152 {
153 if ($cat[0]==$parent)
154 echo "<option value=".$cat[0]." selected>".$cat[1]."</option>";
155 else
156 echo "<option value=".$cat[0].">".$cat[1]."</option>";
157 }
158 ?>
159 </select>
160
161 </td>
162 </tr>
163 <tr>
164 <td width="15%" class="smallfont" align="right">
165 Không hiển thị</td>
166 <td width="1%" class="smallfont" align="right">
167 </td>
168 <td width="83%" class="smallfont">
169 <input type="checkbox" name="chkShow" value="ON" <? if ($status>0) echo 'checked' ?>></td>
170 </tr>
171
172 <tr>
173 <td width="15%" class="smallfont" align="right">
174 Thứ tự sắp xếp</td>
175 <td width="1%" class="smallfont" align="right">
176 </td>
177 <td width="83%" class="smallfont">
178 <INPUT value="<? echo $order; ?>" TYPE="text" NAME="txtSortOrder" CLASS=textbox size="34"></td>
179 </tr>
180 <tr>
181 <td width="15%" class="smallfont">
182 <p align="right">
183 <INPUT TYPE="submit" NAME="butSaveLoai" VALUE="Cập nhật" CLASS=button> </td>
184 <td width="1%" class="smallfont">
185 </td>
186 <td width="83%" class="smallfont"><p align="left"> <INPUT TYPE="reset" CLASS=button value="Nhập lại"></td>
187 </tr>
188 </table>
189 </td>
190 </tr>
191 </table>
192 </form>
2 $path = "../images/cat";
3 $pathdb = "images/cat";
4 if (isset($_POST['butSaveLoai'])) {
5 $parent = $_POST['txtParent'];
6 $order = $_POST['txtSortOrder'];
7 if($order=='') $order=0;
8 else $order = $_POST['txtSortOrder'];
9
10 $status=($_POST['chkShow']!=''?1:0);
11
12 $CategoryName= trim($_POST['txtName']);
13 $err.=CheckUpload($_FILES["txtImage"],".jpg;.gif;.bmp;.png;.swf",500*1024,$_POST['id']==''?1:0);
14 if ($CategoryName=="")
15 {
16 echo "<p align=center class='err'>Bạn chưa nhập tên danh mục</p>";
17 }
18 else
19 {
20 $catinfo=GetCatInfo($parent);
21 $language=$catinfo['language'];
22 if (!empty($_POST['oldid'])) {
23 $oldid = $_POST['oldid'];
24 $sql = "update cat set name='".$CategoryName."', parent='".$parent."', thutu='".$order."', status=".$status." where id='".$oldid."'";
25 }
26 else
27 $sql = "insert into cat (name, parent, thutu, status) values ('".$CategoryName."','".$parent."','".$order."','".$status."')";
28 if (mysql_query($sql,$con)) {
29 if(empty($_POST['id'])) $oldid = mysql_insert_id();
30 $sqlUpdateField = "";
31 $extsmall=GetFileExtention($_FILES['txtImage']['name']);
32 if (MakeUpload($_FILES['txtImage'],"$path/cat_home_s$oldid$extsmall"))
33 {
34 @chmod("$path/cat_home_s$oldid$extsmall", 0777);
35 $sqlUpdateField = " image='$pathdb/cat_home_s$oldid$extsmall' ";
36 }
37 if($sqlUpdateField)
38 {
39 $sqlUpdate = "update cat set $sqlUpdateField where id='".$oldid."'";
40 mysql_query($sqlUpdate,$con);
41 }
42 echo "<p align=center class='err'>Đã cập nhật thành công</p><br>";
43 echo "<script>window.location='index.php?act=category&cat=".$_REQUEST['cat']."&page=".$_REQUEST['page']."'</script>";
44 }
45 else echo "<p align=center class='err'>Không thể cập nhật</p>";
46 }
47 }
48 ?>
49 <?
50 $path = "../images/cat";
51 $pathdb = "images/cat";
52 if (isset($_POST['butSaveLoai'])) {
53 $parent = $_POST['txtParent'];
54 $order = $_POST['txtSortOrder'];
55 if($order=='') $order=0;
56 else $order = $_POST['txtSortOrder'];
57 $status=($_POST['chkShow']!=''?1:0);
58 $CategoryName= trim($_POST['txtName']);
59
60 $err="";
61 if ($CategoryName=="") $err .= "Xin nhập tên<br>";
62 $err.=CheckUpload($_FILES["txtImage"],".jpg;.gif;.bmp;.png;.swf",500*1024,$_POST['id']==''?1:0);
63
64 if ($err=='')
65 {
66 if (!empty($_POST['id'])) {
67 $oldid = $_POST['id'];
68 $sql = "update cat set name='".$CategoryName."', parent='".$parent."', thutu='".$order."', status=".$status." where id='".$oldid."'";
69 }else {
70 $sql = "insert into cat (name, parent, thutu, status) values ('".$CategoryName."','".$parent."','".$order."','".$status."')";
71 }
72 if (mysql_query($sql,$con)) {
73 if(empty($_POST['id'])) $oldid = mysql_insert_id();
74
75 $sqlUpdateField = "";
76
77 $extsmall=GetFileExtention($_FILES['txtImage']['name']);
78 if (MakeUpload($_FILES['txtImage'],"$path/slider_home_s$oldid$extsmall"))
79 {
80 @chmod("$path/slider_home_s$oldid$extsmall", 0777);
81 $sqlUpdateField = " image='$pathdb/slider_home_s$oldid$extsmall' ";
82 }
83 if($sqlUpdateField)
84 {
85 $sqlUpdate = "update cat set $sqlUpdateField where id='".$oldid."'";
86 mysql_query($sqlUpdate,$con);
87 }
88 }
89 else {
90 $err = "<p align=center class='err'>Không thể cập nhật</p>";
91 }
92 }
93 if ($err=='') echo "<script>window.location='index.php?act=category&cat=".$_REQUEST['cat']."&page=".$_REQUEST['page']."'</script>";
94 else echo '<p align=center class="err" style="line-height: 150%">'.$err.'</p>';
95 }
96 ?>
97 <?
98 if (isset($_GET['id'])) {
99 $oldid=$_GET['id'];
100 $sql = "select * from cat where id='".$oldid."'";
101 if ($result = mysql_query($sql,$con)) {
102 $row=mysql_fetch_array($result);
103 $CategoryName=$row['name'];
104 $image=$row['image'];
105 $parent=$row['parent'];
106 $order=$row['thutu'];
107 $status=$row['status'];
108 $date=$row['date'];
109 }
110 }
111 ?>
112
113 <form method="POST" name="FormLoaiSP" enctype="multipart/form-data" action="index.php">
114 <input type=hidden name="act" value="category_m">
115 <input type=hidden name="oldid" value="<? echo $oldid; ?>">
116 <input type=hidden name="page" value="<? echo $_REQUEST['page']; ?>">
117 <input type=hidden name="cat" value="<? echo $_REQUEST['cat']; ?>">
118 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
119 <tr>
120 <td width="45%" align="center" class="title" height="20">Thêm mới / Cập nhật : Danh mục sản phẩm</td>
121 </tr>
122 <tr>
123 <td width="45%">
124 <table border="0" cellpadding="4" bordercolor="#111111" width="124%" id="AutoNumber2" cellspacing="0">
125 <tr>
126 <td width="15%" class="smallfont">
127 <p align="right">Tên danh mục</td>
128 <td width="1%" class="smallfont">
129 <font color="#FF0000">*</font></td>
130 <td width="83%" class="smallfont">
131 <INPUT value="<? echo $CategoryName; ?>" TYPE="text" NAME="txtName" CLASS=textbox size="34"></td>
132 </tr>
133 <tr>
134 <td width="15%" class="smallfont">
135 <p align="right">Hình Icon</td>
136 <td width="1%" class="smallfont" align="center">
137 </td>
138 <td width="83%" class="smallfont">
139 <INPUT TYPE="file" NAME="txtImage" CLASS=textbox size="34"></td>
140 </tr>
141 <tr>
142 <td width="15%" class="smallfont">
143 <p align="right">Thuộc danh mục</td>
144 <td width="1%" class="smallfont">
145 </td>
146 <td width="83%" class="smallfont">
147 <select size="1" name="txtParent">
148 <?
149 echo "<option value='17'>[Danh mục gốc]</option>";
150 $cats=GetListCat(17);
151 foreach ($cats as $cat)
152 {
153 if ($cat[0]==$parent)
154 echo "<option value=".$cat[0]." selected>".$cat[1]."</option>";
155 else
156 echo "<option value=".$cat[0].">".$cat[1]."</option>";
157 }
158 ?>
159 </select>
160
161 </td>
162 </tr>
163 <tr>
164 <td width="15%" class="smallfont" align="right">
165 Không hiển thị</td>
166 <td width="1%" class="smallfont" align="right">
167 </td>
168 <td width="83%" class="smallfont">
169 <input type="checkbox" name="chkShow" value="ON" <? if ($status>0) echo 'checked' ?>></td>
170 </tr>
171
172 <tr>
173 <td width="15%" class="smallfont" align="right">
174 Thứ tự sắp xếp</td>
175 <td width="1%" class="smallfont" align="right">
176 </td>
177 <td width="83%" class="smallfont">
178 <INPUT value="<? echo $order; ?>" TYPE="text" NAME="txtSortOrder" CLASS=textbox size="34"></td>
179 </tr>
180 <tr>
181 <td width="15%" class="smallfont">
182 <p align="right">
183 <INPUT TYPE="submit" NAME="butSaveLoai" VALUE="Cập nhật" CLASS=button> </td>
184 <td width="1%" class="smallfont">
185 </td>
186 <td width="83%" class="smallfont"><p align="left"> <INPUT TYPE="reset" CLASS=button value="Nhập lại"></td>
187 </tr>
188 </table>
189 </td>
190 </tr>
191 </table>
192 </form>